//aboutus
//  huiyuanDetailsViewController.m
//  daogouApp
//
//  Created by panquanReabam.com on 15-6-2.
//  Copyright (c) 2015年 jiezsoft.com. All rights reserved.
//

#import "AboutUsViewController.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "HAODEsingleton.h"
#import "ProductView.h"
#import "UIViewExt.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "huiyuanDetailsCell.h"
#import "UMSocial.h"
#import "SelectTheCertificationViewController.h"
@interface AboutUsViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UIWebViewDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UMSocialUIDelegate>
@property(nonatomic,strong)   NSString*shuoming;
@property(nonatomic,strong)   NSString*shareUrl;

@end

@implementation AboutUsViewController


{
    UIView*beizhuView;
    UILabel *line;
    UIScrollView*mainScroll;
    HAODEsingleton* commdity;
    UIImageView* imageview;
    UILabel *lineLabel1;
    ProductView *clothView;
    NSMutableArray*Memo;
    NSMutableArray*Integral;
    NSMutableArray*Amount;
    NSMutableArray*CreateDate;
    float lastContentOffset;
    UILabel *lineLabel111;
    UIButton*agreementBtn;
    UIButton*agreementBtn1;
    BOOL saveAccount;
    BOOL saveAccount1;
    NSMutableArray* images;
    UIButton*Btn;
    NSMutableArray* arr;
    UITableView *table_list;
    UIWebView*webview;
    UIView*fengxiangview;
    UIButton* quxiao;
    UIScrollView*fengxiangScroll;
    NSDictionary*dataDicts;

}

@synthesize alt = alt;
-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"back.png"];
    CGRect backframe = CGRectMake(0,0,34/3,62/3);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed: @""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
    
    
    
    UIButton* sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
    [sxBtn setImage:[UIImage imageNamed:@"fenxiang"] forState:UIControlStateNormal];
    [sxBtn addTarget:self action:@selector(fenxiangss:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
    self.navigationItem.rightBarButtonItem = myBtnBtn;

    
    
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    commdity=[HAODEsingleton shared];
    self.title = @"关于我们";
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    
//    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
//    NSString* Token = [user objectForKey:@"tokenId"];
//    
//    NSMutableDictionary *params = [NSMutableDictionary new];
//    [params setValue:Token forKey:@"tokenId"];
//    
//    [HttpRequest requestData:@"UserCenter/AboutUs" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
//        if (isSuccess) {
//            NSLog(@"====%@",severDataDict.dataDict);
//            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
//                [Global hideProgressHUDInternal:self.view];
//                
//                webview  = [[UIWebView   alloc]  initWithFrame:CGRectMake( 0,  64,  ScreenWidth ,  ScreenHeight-64)];
//                webview.scalesPageToFit = TRUE;
//                [webview   setUserInteractionEnabled: YES ];	 //是否支持交互
//                [webview   setDelegate: self ];				 //委托
//                [webview   setOpaque: YES ];					 //透明
//                [self.view  addSubview : webview];
//                NSString * path =[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"page"]];
//                ;
//                [webview loadRequest:[NSURLRequest requestWithURL:[[NSURL alloc] initWithString :path]]];
//                
//                
//                
//                
//            }else{
//                [Global hideProgressHUDInternal:self.view];
//                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
//                // [Global showTextHud:requestResultStr view:self.view];
//                [Global showTextHudSub:requestResultStr view:self.view];
//                
//                
//                
//                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==8888) {
//                    
//                    
//                    SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
//                    
//                    [self.navigationController pushViewController:Login animated:YES];
//                    
//                }
//                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==4444) {
//                    [self showAlertMessage:@"账号信息未认证通过，请从新上传"];
//                    
//                    SelectTheCertificationViewController * Login=[[SelectTheCertificationViewController alloc]init];
//                    
//                    [self.navigationController pushViewController:Login animated:YES];
//                    
//                }
//                
//            }
//        }
//        else
//        {
//            [Global hideProgressHUDInternal:self.view];
//            
//            [Global showTextHudSub:@"连接失败" view:self.view];
//            
//            
//            
//        }
//        
//    }];
//    
    
    
    mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight)];
    
    [self.view addSubview:mainScroll];
    [mainScroll setBackgroundColor:[UIColor whiteColor]];
    mainScroll.delegate = self;
    mainScroll.userInteractionEnabled = YES;
    mainScroll.scrollEnabled = YES;
    
    UIImageView* QRCode=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/2-30, 100,60,60) ];
    
    QRCode.image=[UIImage imageNamed:@"logo（120）.png"];
    QRCode.layer.masksToBounds = YES;
    QRCode.layer.cornerRadius = 10;
    QRCode.layer.borderColor = [UIColor whiteColor].CGColor;
    QRCode.layer.borderWidth = 0;
    [mainScroll addSubview:QRCode];
    
    
//    UIButton* update=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2-30, 80,60,60)];
//    [update addTarget:self action:@selector(update:) forControlEvents:UIControlEventTouchUpInside];
//    [mainScroll addSubview:update];
    
    UILabel* ilbel1=[[UILabel alloc]initWithFrame:CGRectMake(0, QRCode.bottom+20, ScreenWidth, 20)];
    ilbel1.text=@"豪德汇";
    ilbel1.textAlignment=NSTextAlignmentCenter;
    ilbel1.textColor=[UIColor blackColor];
    [mainScroll addSubview:ilbel1];
    UILabel* ilbel=[[UILabel alloc]initWithFrame:CGRectMake(0, ilbel1.bottom, ScreenWidth, 20)];
    ilbel.font=[UIFont systemFontOfSize:13];
    ilbel.text=@"版本号V2.0.2";
    ilbel.textAlignment=NSTextAlignmentCenter;
    ilbel.textColor=luseColor;
    [mainScroll addSubview:ilbel];
    
    UILabel* versionlbel11=[[UILabel alloc]initWithFrame:CGRectMake(15, ilbel.bottom+51.5, 60, 15)];
    versionlbel11.text=@"豪德汇,";
    versionlbel11.font=[UIFont systemFontOfSize:15];
    versionlbel11.textColor=[UIColor blackColor];
    [mainScroll addSubview:versionlbel11];
    
    UILabel* versionlbel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,0, 0)];
    NSString *s2 = @"             为互联网+家居建材商贸城打造的专业线上平台，实现进驻商户的线下门店与线上商铺同时运营，通过商品展示、内容运营、需求发布等吸引更多线上客源到店交易。平台更为商户们提供抱团采购和优质服务，提高商户的留存率和进驻率，最终实现传统商贸城互联网化和服务的转型升级。";
    
    UIFont *font2 = [UIFont systemFontOfSize:15];
    CGSize size2 = CGSizeMake(ScreenWidth-30, 2000);
    CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
    
    versionlbel.frame = CGRectMake(15, ilbel.bottom+50, ScreenWidth-30,labelsize2.height);
    versionlbel.textColor=shenhuicolor;
    versionlbel.text =[NSString stringWithFormat:@"%@", s2];
    versionlbel.numberOfLines = 0;
    versionlbel.font=font2;
    [mainScroll addSubview:versionlbel];
    
//    UILabel* versionlbel22=[[UILabel alloc]initWithFrame:CGRectMake(20, versionlbel.bottom+30, 40, 17)];
//    versionlbel22.text=@"支持";
//    versionlbel22.font=[UIFont systemFontOfSize:15];
//    versionlbel22.textColor=zhonghuiColor;
//    versionlbel22.backgroundColor=zuiqianhuicolor;
//    versionlbel22.textAlignment=NSTextAlignmentCenter;
//    [mainScroll addSubview:versionlbel22];
//    
//    UILabel* versionlbel33=[[UILabel alloc]initWithFrame:CGRectMake(versionlbel22.right+2, versionlbel.bottom+30, 160, 15)];
//    versionlbel33.text=@"iphone/iPad";
//    versionlbel33.font=[UIFont systemFontOfSize:15];
//    versionlbel33.textColor=shenhuicolor;
//    [mainScroll addSubview:versionlbel33];
    
    
    
    UILabel* versionlbel1=[[UILabel alloc]initWithFrame:CGRectMake(10,ScreenHeight-50, ScreenWidth-20, 40)];
    versionlbel1.text=@"广州睿本信息科技有限公司 @版权所有All Rights Reserved";
    versionlbel1.font=[UIFont systemFontOfSize:12];
    versionlbel1.numberOfLines = 0;
    versionlbel1.textAlignment = NSTextAlignmentCenter;
    versionlbel1.textColor=[UIColor colorWithRed:153.00/255.00 green:153.00/255.00 blue:153.00/255.00 alpha:1.0];
    [mainScroll addSubview:versionlbel1];
    [mainScroll setContentSize:CGSizeMake(ScreenWidth, ScreenHeight)];

    
}

-(void)closeKeyBoad
{
    [fengxiangview removeFromSuperview];
    [fengxiangScroll removeFromSuperview];
    [quxiao removeFromSuperview];
    
}
-(void)fenxiangss:(UIButton*)sender{
    
    
//    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
//    NSString* Token = [user objectForKey:@"tokenId"];
//    if (Token ==nil) {
//        Token=@"dd";
//    }
//    NSMutableDictionary *param = [NSMutableDictionary new];
//    [param setValue:Token forKey:@"tokenId"];
//    [param setValue:@"Train" forKey:@"contentType"];
//    [param setValue:commdity.reqId forKey:@"contentId"];
//    //[param setValue:@"wx_single" forKey:@"shareTarget"];
//    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
//    
//    
//    [HttpRequest requestData:@"Discover/getShareUrl" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
//        if (isSuccess) {
//            
//            NSLog(@"====%@",severDataDict.dataDict);
//            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
//                [Global hideProgressHUDInternal:self.view];
    
                self.shuoming=@"豪德汇，为互联网+家居建材商贸城打造的专业线上平台，实现进驻商户的线下门店与线上商铺同时运营，通过商品展示、内容运营、需求发布等吸引更多线上客源到店交易。平台更为商户们提供抱团采购和优质服务，提高商户的留存率和进驻率，最终实现传统商贸城互联网化和服务的转型升级。";
                self.shareUrl=@"https://itunes.apple.com/cn/app/hao-de-hui/id1063993065?mt=8";
                
                fengxiangview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
                fengxiangview.backgroundColor=[UIColor blackColor];
                fengxiangview.alpha=0.5;
                [self.view addSubview:fengxiangview];
                
                fengxiangScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,ScreenHeight-240, ScreenWidth,200)];
                fengxiangScroll.delegate = self;
                fengxiangScroll.userInteractionEnabled = YES;
                fengxiangScroll.scrollEnabled = YES;
                fengxiangScroll.showsVerticalScrollIndicator = FALSE;
                fengxiangScroll.showsHorizontalScrollIndicator = FALSE;
                fengxiangScroll.backgroundColor=[UIColor whiteColor];
                [self .view addSubview:fengxiangScroll];
                
                // 手势
                UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
                singleFingerOne.numberOfTouchesRequired = 1; //手指数
                singleFingerOne.numberOfTapsRequired = 1; //tap次数
                singleFingerOne.delegate = self;
                [fengxiangview addGestureRecognizer:singleFingerOne];
                
                
                
                
                NSArray*nameBtn=[[NSArray alloc]initWithObjects:@"发送給朋友",@"分享到朋友圈",nil];
                NSArray *arrayimage = @[@"faweixin",@"fenxiangpenyouquan"];
                for (int i = 0; i<2; i++) {
                    UIButton *nameButcenter = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*i,   80*ScreenHeight/1334+15, ScreenWidth/3, 60)];
                    
                    [fengxiangScroll addSubview:nameButcenter];
                    
                    
                    UIButton *nameBut = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*i,   nameButcenter.bottom+20, ScreenWidth/3, 14)];
                    [nameBut setTitle: [nameBtn objectAtIndex:i]  forState:UIControlStateNormal];
                    nameBut.tag=201+i;
                    [nameBut setTitleColor:shenhuicolor forState:0];
                    nameBut.titleLabel.font=[UIFont systemFontOfSize:14];
                    [nameBut addTarget:self action:@selector(fengxiang:) forControlEvents:UIControlEventTouchUpInside];
                    [fengxiangScroll addSubview:nameBut];
                    
                    
                    UIButton *wuyebuttonimage = [UIButton buttonWithType:UIButtonTypeCustom];
                    wuyebuttonimage.frame = CGRectMake(ScreenWidth/3*i,  10, 60, 60);
                    
                    wuyebuttonimage.tag = 201+i;
                    wuyebuttonimage.center=nameButcenter.center;
                    [wuyebuttonimage setImage:[UIImage imageNamed: [arrayimage objectAtIndex:i]] forState:UIControlStateNormal];
                    [wuyebuttonimage addTarget:self action:@selector(fengxiang:) forControlEvents:UIControlEventTouchUpInside];
                    [fengxiangScroll addSubview:wuyebuttonimage];
                    
                    
                }
                
                
                quxiao = [[UIButton alloc] initWithFrame:CGRectMake(0,ScreenHeight-45,  ScreenWidth, 45)];
                [quxiao setTitle:@"取消" forState:UIControlStateNormal];
                quxiao.titleLabel.font=[UIFont systemFontOfSize:16];
                quxiao.backgroundColor=[UIColor whiteColor];
                [quxiao setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [quxiao addTarget:self action:@selector(closeKeyBoad) forControlEvents:UIControlEventTouchUpInside];
                [self .view addSubview:quxiao];
                UILabel*line11=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 0.35)];
                line11.backgroundColor=qianhuicolor;
                [quxiao addSubview:line11];
                
                
                
//            }else{
//                [Global hideProgressHUDInternal:self.view];
//                
//            }
//            
//        }
//        else
//        {
//            [Global hideProgressHUDInternal:self.view];
//            
//            [Global showTextHudSub:@"连接失败" view:self.view];
//        }
//        
//    }];
    
    
    
    
}

-(void)fengxiang:(UIButton*)sender{
    [fengxiangview removeFromSuperview];
    [fengxiangScroll removeFromSuperview];
    [quxiao removeFromSuperview];
   
    UIImage *image1 = [UIImage imageNamed:@"120x120logos.png"];
    if (sender.tag==201) {
        
        [UMSocialData defaultData].extConfig.wechatSessionData.title = @"豪德汇";
        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeDefault url:self.shareUrl];
        
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        [UMSocialData defaultData].extConfig.wechatSessionData.url = self.shareUrl;
        [[UMSocialDataService defaultDataService]postSNSWithTypes:@[UMShareToWechatSession] content:self.shuoming image:image1 location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){
            
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
            
        }];
        
        
        
        
        
        
    }
    
    if (sender.tag==202) {
        
        //         [UMSocialData defaultData].extConfig.wechatSessionData.title =[commdity.Dict objectForKey:@"itemName"];
        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeDefault url:self.shareUrl];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
        [UMSocialData defaultData].extConfig.wechatTimelineData.url = self.shareUrl;
        [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:[NSString stringWithFormat:@"%@",   @"豪德汇"] image:image1 location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){
            if (response.responseCode == UMSResponseCodeSuccess) {
                NSLog(@"分享成功！");
            }
        }];
        
        
        
        
    }
    
}

- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end